<template>
	<view>
		<u--input placeholder="输入您想修改的名称" border="surround" clearable v-model="name"></u--input>
		<view style="margin-top: 10px;padding: 10px;">
			<u-button type="primary" shape="circle" text="确定" @click="upName"></u-button>
		</view>
		<u-toast ref="uToast" />
	</view>
</template>

<script>
	import {
		upNickName
	} from '@/config/api.js'
	export default {
		data() {
			return {
				name: ''
			}
		},
		methods: {
			upName() {
				if (this.name == '') {
					uni.$u.toast("输入内容不能为空")
				} else {
					let name = '';
					uni.getStorage({
						key: 'user_name',
						success: function(res) {
							name = res.data
						}
					})
					upNickName({}, {
						params: {
							name: name,
							newName: this.name
						}
					}).then(res => {
						uni.$u.toast("修改成功")
						this.name = ''
					}).catch(e => {
						console.log(e);
					})
				}
			},

		}
	}
</script>

<style>

</style>
